package com.jhl.seckill.controller;

import com.jhl.seckill.service.GoodsService;
import com.jhl.seckill.vo.GoodsVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * 该控制器类用于被其他服务调用
 */
@Controller
@RequestMapping("goods")
@Slf4j
public class GoodsByController {
    @Autowired
    GoodsService goodsService;

    @RequestMapping(value = "/findGoods", method = RequestMethod.GET)
    public GoodsVo findGoodsVobyGoodsId(Long goodsId) {
        GoodsVo goodsVo = goodsService.findGoodsVobyGoodsId(goodsId);
        return goodsVo;
    }

    @RequestMapping(value = "/findGoodsVo", method = RequestMethod.GET)
    @ResponseBody
    List<GoodsVo> findGoodsVo() {
        log.info("订单服务调用商品服务的findGoodsVo方法");
        List<GoodsVo> goodsVo = goodsService.findGoodsVo();
        return goodsVo;
    }
}
